#include "PhysFSCommon.h"

#include "physfs.h"

#ifndef _PHYSFS_PHYFS_STEAM_H_
#define _PHYSFS_PHYFS_STEAM_H_

namespace Hiranipra {
	namespace Platform {
		namespace IO {

			class PhysFSStream : implements IFileStream
			{
			public:
				PhysFSStream( const PHYSFS_File* handle, bool readOnly );
				virtual ~PhysFSStream();

				virtual int64 GetLength() const;

				virtual void SetBuffer( const uint32 bufferSize );
				virtual void Flush();
				virtual void Close();

				virtual int64 GetPosition() const;
				virtual bool SetPosition( const int64 position );
				virtual bool IsEOF() const;

				virtual uint32 Read( void* buffer, uint32 size );
				virtual uint32 Write( const void* buffer, uint32 size );

				virtual uint32 Read( MemoryBuffer* buffer, uint32 toRead );
				virtual uint32 Write( MemoryBuffer* buffer );

				virtual bool ReadAll( MemoryBuffer& buffer );

			private:
				PHYSFS_File*	_handle;
				bool			_isOpen;
				bool			_readOnly;
			};

		}
	}
}

#endif // _PHYSFS_PHYFS_STEAM_H_
